The present invention relates generally to microprocessors, and more specifically to microprocessors capable of speculatively reusing regions of software code.
Modern software programs include many instructions that are executed multiple times each time the program is executed. Typically, large programs have logical xe2x80x9cregionsxe2x80x9d of instructions, each of which may be executed many times. When a region is one that is executed more than once, and the results produced by the region are the same for more than one execution, the region is a candidate for xe2x80x9creuse.xe2x80x9d The term xe2x80x9creusexe2x80x9d refers to the reusing of results from a previous execution of the region.
For example, a reuse region could be a region of software instructions that, when executed, read a first set of registers and modify a second set of registers. The data values in the first set of registers are the xe2x80x9cinputsxe2x80x9d to the reuse region, and the data values deposited into the second set of registers are the xe2x80x9cresultsxe2x80x9d of the reuse region. A buffer holding inputs and results can be maintained for the region. Each entry in the buffer is termed an xe2x80x9cinstance.xe2x80x9d When the region is encountered during execution of the program, the buffer is consulted and if an instance with matching input values is found, the results can be used without having to execute the software instructions in the reuse region. When reusing the results is faster than executing the software instructions in the region, performance improves.
However, in order to achieve performance improvement, a large number of instances must be maintained for each reuse region, thereby increasing the cost involved in reusing regions of software instructions. Similarly, when execution of a reuse region creates a large number of results, reuse is costly and inefficient as the likelihood of reusing each of the multiple results decreases.
Another problem with reuse arises when the reuse region contains a memory load instruction that accesses a memory location modified by a memory update instruction outside the region. For such regions (called xe2x80x9caliasedxe2x80x9d regions), even when a matching instance exists in the buffer, the reuse instance may not be usable because the aliased memory load may read a different value that causes the correct results to differ from the results in the instance. Furthermore, current microprocessors lack any reuse capability when no matching instance is found in the buffer.
Therefore, it would be advantageous to provide an alternate method and apparatus for reusing regions of software code.